home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-k-archive.past / tex-k-archive.gz / tex-k-archive / 000162_simon@lia.di.epfl.ch_Mon Jan 17 12:39:03 1994.msg < prev    next >
Internet Message Format  |  1994-10-11  |  3KB

  1. Received: from liasun6.epfl.ch by cs.umb.edu with SMTP id AA22059
  2.   (5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Mon, 17 Jan 1994 12:39:03 -0500
  3. Received: by liasun6.epfl.ch (Smail3.1.28.1 #58)
  4.     id m0pLxum-0002P8C; Mon, 17 Jan 94 18:39 MET
  5. Message-Id: <m0pLxum-0002P8C@liasun6.epfl.ch>
  6. Date: Mon, 17 Jan 94 18:39 MET
  7. From: simon@lia.di.epfl.ch (Simon Leinen)
  8. To: tex-k@cs.umb.edu
  9. Subject: xdvik-1.4: SIGIO handling broken for POSIX systems
  10. In-Reply-To: <"swan.cl.cam.:121540:931022092439"@cl.cam.ac.uk>
  11. References: <"swan.cl.cam.:121540:931022092439"@cl.cam.ac.uk>
  12.  
  13. Hello,
  14.  
  15.   xdvik-1.4 includes a fix proposed by Martyn Johnson (see the
  16. referenced message to this list).  Unfortunately (1) the fix wasn't
  17. integrated correctly and (2) although the idea is good, the fix itself
  18. has a bug.  Martyn's fix was:
  19.  
  20. > Solution 2:
  21. >   Use "sigaction" rather than "signal", and set the SA_RESTART flag
  22. > explicitly.  I prefer this approach, because not all vendors may
  23. > follow Digital's approach of offering a whole family of alternative
  24. > compatibility modes.  A possible patch would be:
  25. > *** 1.1 1993/10/21 14:06:44
  26. > --- xdvi.c      1993/10/22 08:43:59
  27. > ***************
  28. > *** 2026,2032 ****
  29. > --- 2026,2036 ----
  30. >             if (dup2(socket, 0) == -1) perror(prog);
  31. >             socket = 0;
  32. >         }
  33. > + #ifdef SA_RESTART
  34. > +       (void) sigaction(SIGIO, (handle_intr, 0, SA_RESTART), NULL);
  35. > + #else
  36. >         (void) signal(SIGIO, handle_intr);
  37. > + #endif SA_RESTART
  38. >         (void) fcntl(socket, F_SETOWN, getpid());
  39. >         (void) fcntl(socket, F_SETFL, fcntl(socket, F_GETFL, 0) | FASYNC);
  40. >   }
  41.  
  42. but in xdvik/xdvi.c I see (lines 2029-2034):
  43.  
  44. #ifdef SA_RESTART
  45.         (void) sigaction(SIGIO, (handle_intr, 0, SA_RESTART), NULL);
  46. #else
  47.         (void) signal(SIGIO, handle_intr);
  48. #endif /* SA_RESTART */
  49.     (void) signal(SIGIO, handle_intr);
  50.  
  51. So there is one signal() call too much.  Probably this doesn't really
  52. matter.  The real problem is that the second parameter to sigaction()
  53. is wrong.  If I use this code under IRIX 5, I get spurious SIGIOs that
  54. terminate xdvi.  Here is a patch to xdvik-1.4 that fixes both bugs.
  55. -- 
  56. Simon.
  57.  
  58. *** xdvik/xdvi.c    1994/01/17 17:34:14    1.1
  59. --- xdvik/xdvi.c    1994/01/17 17:35:59    1.2
  60. ***************
  61. *** 2028,2036 ****
  62.       }
  63.   #ifdef SA_RESTART
  64. !         (void) sigaction(SIGIO, (handle_intr, 0, SA_RESTART), NULL);
  65.   #else
  66.           (void) signal(SIGIO, handle_intr);
  67.   #endif /* SA_RESTART */
  68. -     (void) signal(SIGIO, handle_intr);
  69.       (void) fcntl(socket, F_SETOWN, getpid());
  70.       (void) fcntl(socket, F_SETFL, fcntl(socket, F_GETFL, 0) | FASYNC);
  71. --- 2028,2041 ----
  72.       }
  73.   #ifdef SA_RESTART
  74. !     {
  75. !       struct sigaction sa;
  76. !       sa.sa_handler = handle_intr;
  77. !       sigemptyset (& sa.sa_mask);    
  78. !       sa.sa_flags = SA_RESTART;
  79. !       (void) sigaction(SIGIO, &sa, NULL);
  80. !     }
  81.   #else
  82.           (void) signal(SIGIO, handle_intr);
  83.   #endif /* SA_RESTART */
  84.       (void) fcntl(socket, F_SETOWN, getpid());
  85.       (void) fcntl(socket, F_SETFL, fcntl(socket, F_GETFL, 0) | FASYNC);